function searchThreadsDisplay(data) {

	$("#xml").text(serialiseXml(data));

	var html = "<table id='searchResultsTable' class='table'>";

	html += "<thead class='tablehead'><th class='tableheadcell'>Board Name</th><th class='tableheadcell'>Result</th><th class='tableheadcell'>Started By</th><th class='tableheadcell'>Creation Date</th></thead>";

	$(data).find("Responses > Search > Results > Result").each(function() {

		var boardId = $(this).find("BoardId").text();
		var threadId = $(this).find("ThreadId").text();
		var url = "#" + boardId + "-" + threadId;

		html += "<tr class='row'>";
		html += "<td class='cell'>";
		html += $(this).find("BoardName").text() + "</td>";
		html += "<td class='cell'><a href='" + url + "'>" + $(this).find("ThreadTitle").text() + "</a></td>";
		html += "<td class='cell'>" + $(this).find("DisplayName").text() + "</td>";

		var creationDate = $(this).find("CreationDate").text();
		var date = new Date();
		date.setISO(creationDate);
		creationDate = Globalize.format(date, "MMM yyyy");

		html += "<td class='cell'>" + creationDate + "</td>";
		html += "</tr>";
	});

	html += "</table>";

	$("#mainPanel").html(html);
	$("#searchTextField").val("");
	
	$("#boardLink").html(" <span class='boardLink'>&gt; Search Results</span>").show();
}

function searchThreadsCallback(data, status, request) {
	searchThreadsDisplay(data);
}

function searchThreads(queryString, offset, responses) {

	xml = "<Requests>";
	xml += searchThreadTitlesMessage(queryString, offset, responses);
	xml += "</Requests>";

	sendMessage(xml, searchThreadsCallback);
}